package com.lcfc.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lcfc.bean.Buser;
import com.lcfc.service.UserService;
import com.lcfc.service.impl.UserServiceImpl;
import com.lcfc.utils.Tools;

/**
 * 查询用户周边商户
 * 
 * @author Samer.he
 * @date 2016.6.27
 */
public class QueryBuserServlet extends HttpServlet {

	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// 查询用户周边半径商户，并返回json 数据
		req.setCharacterEncoding("utf-8");
		//resp.setCharacterEncoding("utf-8");
		resp.setContentType("text/html;charset=UTF-8");
		UserService service = new UserServiceImpl();
		ArrayList<Buser> list = service.queryBuserByDistance(1, 37.134567d, 116.553535d);
		String json = Tools.bean2Json(list);
		System.out.println(json);
		PrintWriter writer = resp.getWriter();
		writer.write(json);
		writer.close();

	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doGet(request, response);
	}

}
